Map styles import

Hi all,

You know how you can create a styles map file for exporting RTFs from word right?

There's this dialog box that comes up asking you to map Word header, text styles to DOORS heading/obj text styles.

You can save this style map and load it as a template in other exports.

Is it possible to make use of this map when you use the function importRTF inside DOORS?

When you put the bool mapStyles to true, then it will map all familiar styles, but unfamiliar styles will cause a dialog box to pop up. So if you have 3 different heading styles, you have to click the confirm button 3 times.

Is there a way to access this map file so that it will import the RTF the same way Word exports the RTF?

Thanks,

Too Diff
TooDifficult - Thu Dec 09 17:24:59 EST 2010

Re: Map styles import
SystemAdmin - Mon Dec 13 18:21:02 EST 2010

Hi,

Rather than using the DXL function ImportRTF - perhaps have a look at the DXL code that DOORS uses for the File>Import>Rich Text Format menu item. This might provide some clues\hooks that you can use - it's location and file name is ....\IBM\Rational\DOORS\9.2\lib\dxl\standard\import\rtfim.dxl


Paul Miller
Melbourne, Australia

Re: Map styles import
TooDifficult - Tue Dec 14 20:13:08 EST 2010

SystemAdmin - Mon Dec 13 18:21:02 EST 2010
Hi,

Rather than using the DXL function ImportRTF - perhaps have a look at the DXL code that DOORS uses for the File>Import>Rich Text Format menu item. This might provide some clues\hooks that you can use - it's location and file name is ....\IBM\Rational\DOORS\9.2\lib\dxl\standard\import\rtfim.dxl


Paul Miller
Melbourne, Australia

Oh good idea.

Thanks for that. I'll have a look.

TooDiff

Re: Map styles import
TooDifficult - Tue Dec 14 21:50:37 EST 2010

TooDifficult - Tue Dec 14 20:13:08 EST 2010
Oh good idea.

Thanks for that. I'll have a look.

TooDiff

========FROM RTFIM.DXL========
// remap 0 = level 1 to 1 = level 1
// remap 9 = object text to 0 = object text
// remap 10 = level 10 to 10 = level 10

for style in impStyleSkip do {
if (!find(impSkipMapping, (int key impStyleSkip), map))
map = -1
map++
if (map == 10) {
map = 0
} else if (map > 10) {
map--
}
find(impSkipLHB, (int key impStyleSkip), name)
put(mapping, style, map)

====FROM IMPORTIF.INC=====

void impMapLoadSettings(string filename) {
if (!fileOK(filename, (NLS_("map")), false))
return

string s, token1, token2, token3, rest, format
int i, j
Stream fileIn
Skip skipLHB = create
Skip skipRHB = create
Skip skipMap = create
int skipLHBNum = 0
int skipRHBNum = 0

fileIn = read filename

format = (NLS_(""))
fileIn >> s
while (!end fileIn) {
token1 = impGetToken(s, token2)
if (token1 == (NLS_("Import format")) ) {
format = impGetToken(token2, token3)
} else if (token1 == (NLS_("LHB"))) {
put(skipLHB, skipLHBNum++, impGetToken(token2, token3))
} else if (token1 == (NLS_("RHB"))) {
put(skipRHB, skipRHBNum++, impGetToken(token2, token3))
} else if (token1 == (NLS_("Mapping"))) {
token2 = impGetToken(token2, token3)
token3 = impGetToken(token3, rest)
i = intOf token2
j = intOf token3
put(skipMap, i, j)
} else if (token1 == (NLS_("Option"))) {
token2 = impGetToken(token2, token3)
token3 = impGetToken(token3, rest)
impLoadOption(token2, token3)
}
if (format != impFormat) {
break
}
fileIn >> s
}

close fileIn

if (format != impFormat) {
if (format == (NLS_("")))
{
impLoadOldMapFile(filename)
}
else
{
warningBox (LS_("String_Map_file_is_not_of_s_format_n_It_is_of_s_format",NLSTEMP_("Map file is not of %s format\nIt is of %s format")), impFormat, format)
}
delete skipLHB
delete skipRHB
delete skipMap
return
}

impDeleteSkips
impCreateSkips
i = 0
for s in skipLHB do
put(impSkipLHB, i++, s)

i = 0
for s in skipRHB do
put(impSkipRHB, i++, s)

for j in skipMap do
put(impSkipMapping, (int key skipMap), j)

impDeleteListContents impMapLHB
impDeleteListContents impMapRHB
impInitLists
impMapLHBUpdate
impLoadOptionsComplete()

delete skipLHB
delete skipRHB
delete skipMap

}

==================

The first code is the remapping I believe...

The second snippet is loading a style map. Can you confirm this? It's confusing...

But I believe the loading part will work if I call it into my own RTF function...because I have already manually saved a .map file.

I think it will work if I can figure out what it's doing. One problem is that importRTF() has a mind of its own, I think it only has the bool option of mapping styles, from which it asks the user to enter them in real time, instead of referring to a style map.

How do you think I can modify this?

Thanks,

TooDiff

Re: Map styles import
SystemAdmin - Wed Dec 15 17:26:57 EST 2010

TooDifficult - Tue Dec 14 21:50:37 EST 2010
========FROM RTFIM.DXL========
// remap 0 = level 1 to 1 = level 1
// remap 9 = object text to 0 = object text
// remap 10 = level 10 to 10 = level 10

for style in impStyleSkip do {
if (!find(impSkipMapping, (int key impStyleSkip), map))
map = -1
map++
if (map == 10) {
map = 0
} else if (map > 10) {
map--
}
find(impSkipLHB, (int key impStyleSkip), name)
put(mapping, style, map)

====FROM IMPORTIF.INC=====

void impMapLoadSettings(string filename) {
if (!fileOK(filename, (NLS_("map")), false))
return

string s, token1, token2, token3, rest, format
int i, j
Stream fileIn
Skip skipLHB = create
Skip skipRHB = create
Skip skipMap = create
int skipLHBNum = 0
int skipRHBNum = 0

fileIn = read filename

format = (NLS_(""))
fileIn >> s
while (!end fileIn) {
token1 = impGetToken(s, token2)
if (token1 == (NLS_("Import format")) ) {
format = impGetToken(token2, token3)
} else if (token1 == (NLS_("LHB"))) {
put(skipLHB, skipLHBNum++, impGetToken(token2, token3))
} else if (token1 == (NLS_("RHB"))) {
put(skipRHB, skipRHBNum++, impGetToken(token2, token3))
} else if (token1 == (NLS_("Mapping"))) {
token2 = impGetToken(token2, token3)
token3 = impGetToken(token3, rest)
i = intOf token2
j = intOf token3
put(skipMap, i, j)
} else if (token1 == (NLS_("Option"))) {
token2 = impGetToken(token2, token3)
token3 = impGetToken(token3, rest)
impLoadOption(token2, token3)
}
if (format != impFormat) {
break
}
fileIn >> s
}

close fileIn

if (format != impFormat) {
if (format == (NLS_("")))
{
impLoadOldMapFile(filename)
}
else
{
warningBox (LS_("String_Map_file_is_not_of_s_format_n_It_is_of_s_format",NLSTEMP_("Map file is not of %s format\nIt is of %s format")), impFormat, format)
}
delete skipLHB
delete skipRHB
delete skipMap
return
}

impDeleteSkips
impCreateSkips
i = 0
for s in skipLHB do
put(impSkipLHB, i++, s)

i = 0
for s in skipRHB do
put(impSkipRHB, i++, s)

for j in skipMap do
put(impSkipMapping, (int key skipMap), j)

impDeleteListContents impMapLHB
impDeleteListContents impMapRHB
impInitLists
impMapLHBUpdate
impLoadOptionsComplete()

delete skipLHB
delete skipRHB
delete skipMap

}

==================

The first code is the remapping I believe...

The second snippet is loading a style map. Can you confirm this? It's confusing...

But I believe the loading part will work if I call it into my own RTF function...because I have already manually saved a .map file.

I think it will work if I can figure out what it's doing. One problem is that importRTF() has a mind of its own, I think it only has the bool option of mapping styles, from which it asks the user to enter them in real time, instead of referring to a style map.

How do you think I can modify this?

Thanks,

TooDiff

How do you think I can modify this?

Good question!! I'm afraid that I only knew of the existance of this file, I'm not familiar with how the DXL code in this file works or how to quickly get it to work for your specific need without spending some significant time trying to get a handle on what it's doing. Hopefully others with a better knowledge of RTF imports can help here.


Paul Miller
Melbourne, Australia